package com.zcx.mall.common.web.api;

import com.zcx.mall.common.web.exception.BizExcepton;
import lombok.Data;

@Data
public class ApiResult<T> {

    private String code;

    private String msg;

    private T content;

    public ApiResult() {
        this.code = "0000";
        this.msg = "操作成功";
        this.content = null;
    }

    public ApiResult(BizExcepton bizExcepton) {
        this.code = bizExcepton.getErrorCode();
        this.msg = bizExcepton.getMessage();
        this.content = null;
    }

    public ApiResult(T content) {
        this.code = "0000";
        this.msg = "操作成功";
        this.content = content;
    }

    public ApiResult(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }


    public static ApiResult paramError(String message) {
        return new ApiResult("0001", message);
    }
}
